<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
    require_once("class.connectSQL.inc");
    
    //instancia da classe
    $banco = new connectSQL();
	
	if(isset($_POST["foto"])){
		
		 
			$sql = "UPDATE tpservicos set id_foto = '".$_POST["foto"]."'"
                                . " where idtpservicos = ".$_GET["cod"];
			
			
			$banco->Generico($sql);
			//die($_POST["acao"]);
			
		
		
		}
		
		
?>


				<?php
					 $resultado = $banco->Query("SELECT * FROM foto");
				?>
                     
        
                <!-- Example table -->
                <div class="module">
                	<h2>Foto - Escolha uma</h2>
                    
                    <div class="module-table-body">
                        <form action="foto.php?cod=<?php echo $_GET["cod"]; ?>" method="post">
                        <table id="myTable" class="tablesorter">
                        	
                                <tr>
                                    <th style="width:5%">#</th>
                                    <th style="width:20%">Nome</th>
                                    <th style="width:40%">Imagem</th>
                                    
                                </tr>
                            
                            <tbody>
                            <?php
                            
    
        foreach ($resultado as $resut){
        echo "<tr>";
		echo "<td>". $resut['id_foto']."</td>";
                echo "<td>". $resut['nome']."</td>";
		echo  "<td><img src='". $resut['caminho']."'  width='100' height='100' alt='edit' /></td>";
              
               echo  "<td><input type='radio' name='foto' value='". $resut['id_foto']."'></td>";
                
		?>
        <?php ?>
        
            <?php  
		
			
  		echo "</tr>";
		}
   		                  ?>  
                                
                                             
                     
                     
                      </tbody>
                        </table>
                            <input type="submit" value="Salvar" />
                        </form>
                     
                     
                 </div>  
        